package com.sugar.domain.system.privilege;

import java.util.Date;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * @标题：模块资源实体
 * @描述：模块列表的资源（CRUD...）
 * @编写者：杨浩泉
 * @日期：2011-6-1 <b>下午03:53:29</b>
 */
@Entity@Table(name="sugar_PrivilegeResourceItem")
public class PrivilegeResourceItem {

	private int mc_id ;
	
	private String mc_name ;
	
	private String mc_desc ;
	
	private String mc_url ;
	
	private Set<PrivilegeResourceItem> child ;
	
	private PrivilegeResourceItem parent ;
	
	@OneToMany
	@JoinColumn(name="item_pid")
	public Set<PrivilegeResourceItem> getChild() {
		return child;
	}

	public void setChild(Set<PrivilegeResourceItem> child) {
		this.child = child;
	}

	@ManyToOne
	@JoinColumn(name="item_pid")
	public PrivilegeResourceItem getParent() {
		return parent;
	}

	public void setParent(PrivilegeResourceItem parent) {
		this.parent = parent;
	}

	public String getMc_url() {
		return mc_url;
	}

	public void setMc_url(String mcUrl) {
		mc_url = mcUrl;
	}

	private Date addTime = new Date() ;
	
	private PrivilegeResourceModel mlist ;
	
	private Set<PrivilegeRole> role ;
	
	@ManyToMany(mappedBy="mres")
	@JoinTable(name="sugar_privilege_role_resource",
			joinColumns={@JoinColumn(name="resid_roleid")},
			inverseJoinColumns={@JoinColumn(name="roleid_resid")}
			)
	public Set<PrivilegeRole> getRole() {
		return role;
	}

	public void setRole(Set<PrivilegeRole> role) {
		this.role = role;
	}

	@ManyToOne
	@JoinColumn(name="ml_id")
	public PrivilegeResourceModel getMlist() {
		return mlist;
	}

	public void setMlist(PrivilegeResourceModel mlist) {
		this.mlist = mlist;
	}

	@Id@GeneratedValue
	public int getMc_id() {
		return mc_id;
	}

	public void setMc_id(int mcId) {
		mc_id = mcId;
	}

	public String getMc_name() {
		return mc_name;
	}

	public void setMc_name(String mcName) {
		mc_name = mcName;
	}

	public String getMc_desc() {
		return mc_desc;
	}

	public void setMc_desc(String mcDesc) {
		mc_desc = mcDesc;
	}

	public Date getAddTime() {
		return addTime;
	}

	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}
	
}
